﻿using K9Nano.Application.Dtos;
using K9Nano.Authorization;
using K9Nano.Domain.Entities;

namespace K9Nano.Application.Authentication;

public interface IUserAppServiceBase<TUser, in TCreateDto, in TEditDto, TItemDto, in TQueryDto>
    : ICurdAppServiceBase<TUser, TCreateDto, TEditDto, TItemDto, TQueryDto>
    where TUser : UserBase
    where TEditDto : IKeyDto
    where TQueryDto : UserQueryDto<TUser>
{
    /// <summary>
    /// 修改用户状态
    /// </summary>
    Task SetStatusAsync(UserStatusEditDto dto, CancellationToken cancellation);

    /// <summary>
    /// 为用户批量添加角色
    /// </summary>
    Task AddRolesAsync(UserRoleEditDto dto, CancellationToken cancellation);

    /// <summary>
    /// 获取用户的权限列表
    /// </summary>
    Task<IEnumerable<Permission>> GetPermissionsByUserIdAsync(long userId, CancellationToken cancellation);

    /// <summary>
    /// 获取用户的角色列表
    /// </summary>
    Task<IEnumerable<RoleDto>> GetRolesByUserIdAsync(long userId, CancellationToken cancellation);

    /// <summary>
    /// 为用户批量删除角色
    /// </summary>
    Task RemoveRolesAsync(UserRoleEditDto dto, CancellationToken cancellation);

    /// <summary>
    /// 为用户重置密码
    /// </summary>
    Task<bool> ResetPasswordAsync(UserResetPasswordDto dto, CancellationToken cancellation);

    /// <summary>
    /// 设置用户归属组织
    /// </summary>
    Task SetOrganizationAsync(ChangeUserOrganizationDto dto, CancellationToken cancellation);

    /// <summary>
    /// 获取组织下的用户列表
    /// </summary>
    /// <param name="organizationId">组织ID</param>
    /// <returns></returns>
    Task<TItemDto[]> GetUsersByOrganizantionIdAsync(long organizationId, CancellationToken cancellation);
}